// MemoryAllocation.h: interface for the CMemoryManager class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MEMORYMANAGER_MALLOC_H__83A5DC65_A4FF_4A75_8531_38447B1F4A73__INCLUDED_)
#define AFX_MEMORYMANAGER_MALLOC_H__83A5DC65_A4FF_4A75_8531_38447B1F4A73__INCLUDED_

//#include "HQM3DPredefine.h"
//#include "HQM2DPredefine.h"
//#ifndef IPHONEOS

#ifdef __SYMBIAN32__

void* malloc(unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber);
void free(void* block);

void* operator new(unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber);
void* operator new[](unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber);

void* operator new (unsigned int in_nSize,int xxx=0);
void* operator new[](unsigned int in_nSize,int xxx=0);

#define MALLOC(size) malloc((size),(__FILE__),(__LINE__))
#define NEW new((__FILE__),(__LINE__))
#define DELETE delete

#elif defined _WIPIVERSION

void* malloc(unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber);
void free(void* block);

void* operator new(unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber);
void* operator new[](unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber);
void* operator new(unsigned int blocksize);
void* operator new[](unsigned int blocksize);
void  operator delete( void* block );
void  operator delete[]( void* block );

#define MALLOC(size) malloc((size),(__FILE__),(__LINE__))
#define NEW new((__FILE__),(__LINE__))
#define DELETE delete
//#define NEW[] new[]((__FILE__),(__LINE__))

#elif defined _BREWVERSION

#include "AEEStdLib.h"

	#define DEBUG_PRINT(P1, P2)	{	\
		DBGPRINTF(P1, P2);	\
		uint32 t1 = GETUPTIMEMS();	\
		while (true)	\
		{	\
			uint32 t2 = GETUPTIMEMS();	\
			if (t2 - t1 >= 600) break;	\
		}}

inline void* operator new (unsigned int in_nSize){	return MALLOC(in_nSize); }
inline void* operator new[](unsigned int in_nSize) { return MALLOC(in_nSize); }
inline void operator delete (void * in_pAddr) { FREE(in_pAddr); }
inline void operator delete[](void * in_pAddr) { FREE(in_pAddr); }

#define NEW new
#define DELETE delete

#else

#include <string.h>

//#define _USEMEMMANAGER

#ifndef _USEMEMMANAGER
	#define MEMSTACK_BEGIN_SNAPSHOT		
	#define MEMSTACK_END_SNAPSHOT		

//	extern	void* operator new (unsigned int in_nSize,int xxx);
//	extern	void* operator new[](unsigned int in_nSize,int xxx);

//	#define NEW new(1)
//	#define DELETE delete
	void* malloc(int blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
	void free(void* block,int xxx,int xxx2);
#ifndef IPHONEOS
	//void* operator new(unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
	//void* operator new[](unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
#else
	void* operator new(size_t blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
	void* operator new[](size_t blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
#endif
	//void  operator delete( void* block );
	//void  operator delete[]( void* block );

	#define NEW new//(__FILE__, __LINE__,1,2)
	#ifdef DELETE
	#undef DELETE
	#endif
	#define DELETE delete
	#define MALLOC(a) malloc(a,__FILE__, __LINE__,1,2)
#else
	#define MEMSTACK_BEGIN_SNAPSHOT		MemStack_Begin_SnapShot();
	#define MEMSTACK_END_SNAPSHOT		MemStack_End_SnapShot();
	void MemStack_Begin_SnapShot();
	void MemStack_End_SnapShot();

	void* malloc(int blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
	void free(void* block,int xxx,int xxx2);
	void* operator new(unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
	void* operator new[](unsigned int blocksize, const char* in_pszFileName, const int in_nLineNumber,int xxx,int xxx2);
//	void  operator delete( void* block );
//	void  operator delete[]( void* block );

	#define NEW new(__FILE__, __LINE__,1,2)
	#define DELETE delete
	#define MALLOC(a) malloc(a,__FILE__, __LINE__,1,2)
#endif
	
//#endif
#endif

#endif // !defined(AFX_MEMORYMANAGER_MALLOC_H__83A5DC65_A4FF_4A75_8531_38447B1F4A73__INCLUDED_)
